package testBaGu;

//浅拷贝
class Person implements Cloneable{
    String name;
    Address address;
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
class Address{
    String city;
}
public class ShallowCopyExample{
    public static void main(String[]args) throws CloneNotSupportedException{
        Person person1=new Person();
        person1.name="John";
        person1.address=new Address();
        person1.address.city="New York";

        Person person2=(Person) person1.clone();
        System.out.println(person1==person2);
        System.out.println(person1.address==person2.address);
    }
}
